package com.ug.system.controller;

import com.ug.common.constant.SecurityConstants;
import com.ug.common.response.ResponseMessage;
import com.ug.common.response.ResponseMessageFactory;
import com.ug.system.entity.monitor.RedisCacheInfo;
import com.ug.system.entity.monitor.ServerInfo;
import com.ug.system.service.MonitorApplicationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author LY
 * @create 2024/8/2 14:46
 * @Description 服务信息监控
 */
@Tag(name = "MonitorController", description = "监控管理")
@RestController
@RequestMapping("/monitor")
@RequiredArgsConstructor
public class MonitorController {

    private final MonitorApplicationService monitorApplicationService;

    /**
     * 应用服务器环境信息
     */
    @Operation(summary = "应用服务器环境信息", security = { @SecurityRequirement(name = SecurityConstants.TOKEN_HEADER) })
    @GetMapping("/serverInfo")
    public ResponseMessage<ServerInfo> getServerInfo(){
        return ResponseMessageFactory.getSuccessResponseMessage(monitorApplicationService.getServerInfo());
    }

    /**
     * redis缓存服务信息
     */
    @Operation(summary = "redis缓存服务信息", security = { @SecurityRequirement(name = SecurityConstants.TOKEN_HEADER) })
    @GetMapping("/redisCacheInfo")
    public ResponseMessage<RedisCacheInfo> getRedisCacheInfo(){
        return ResponseMessageFactory.getSuccessResponseMessage(monitorApplicationService.getRedisCacheInfo());
    }
}
